from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel, Field


# 定义请求数据模型
class ImageProcessItem(BaseModel):
    img: str = Field(
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/face_replace/20230720/5cfd3b3887c77c89f65eaf64f73af1ab.png",
        description="用户的头像")
    obj_img: str = Field(
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/face_replace/20230628/wecom-temp-d849d6f5ba80f73c294b01ca4ea86bce.png",
        description="目标换脸的图像")
    shuiyin: bool = Field(True, description="是否需要加水印")


# 定义响应数据模型
class ImageProcessResult(BaseModel):
    res_url: str
    all_url: str
    duration: float
    # 错误信息的字段,默认是空
    error_message: Optional[str] = None


class RoopItem(BaseModel):
    video_url: str = Field(
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/videos/20230628/74011b30c0cd50cd4a7dd1fa29a6368f_final.mp4",
        description="视频的URL地址")
    user_img_url: str = Field(
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/face_replace/20230720/5cfd3b3887c77c89f65eaf64f73af1ab.png",
        description="用户图片的URL地址")
    frames: int = Field(15, description="帧数")
    callback: bool = Field(True, description="是否有回调通知")
    shuiyin: bool = Field(True, description="是否需要加水印")


class SlideItem(BaseModel):
    '''
        # Models需要下面的信息
    transition_effect = "wiperight"
    transition_duration = 0.7
    audio_path = "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/output_audio.mp3"
    images_paths_urls = [
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image1.jpg",
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image2.jpg",
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image3.jpg"
    ]
    '''

    transition_effect: str = Field("wiperight", description="转场效果")
    transition_duration: float = Field(0.7, description="转场时间")
    audio_path: str = Field("https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/output_audio.mp3", description="音频地址")
    images_paths_urls: list = Field([
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image1.jpg",
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image2.jpg",
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image3.jpg"
    ], description="图片地址列表")


class SlideV2Item(BaseModel):
    ''''

    audio_url = "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/output_audio.mp3"

    image_list_data = [
        {"图片地址": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image1.jpg", "转场时间": 0.7, "持续时间": 2,
         "转场效果": "fade"},
        {"图片地址": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image2.jpg", "转场时间": 0.7, "持续时间": 3,
         "转场效果": "wipeup"},
        {"图片地址": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image3.jpg", "转场时间": 0.7, "持续时间": 3,
         "转场效果": "fade"}
    ]
    '''
    images_paths_urls: list = Field([
        {"图片地址": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image1.jpg", "转场时间": 0.7, "持续时间": 2,
         "转场效果": "fade"},
        {"图片地址": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image2.jpg", "转场时间": 0.7, "持续时间": 3,
         "转场效果": "wipeup"},
        {"图片地址": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image3.jpg", "转场时间": 0.7, "持续时间": 3,
         "转场效果": "fade"}
    ])


class RoopResult(BaseModel):
    task_id: str = Field(..., description="任务的ID")
    # video_loc_url: str = Field(..., description="换脸目标的视频的url地址")
    # loc_user_path_path: str = Field(..., description="用户本地的路径")
